package com.tueye.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tueye.ajax.json.JSONObject;
import com.tueye.service.IBuilderHtml;


/**
 * 生成模板控制器
 * 
 * @author hanxiaowei
 *
 */
@SuppressWarnings("unchecked")
@org.springframework.stereotype.Controller
@RequestMapping("/builderTemplate.do")
public class BuilderTemplateController  extends BaseController {

	private static final Log log = LogFactory.getLog(BuilderTemplateController.class);
	
	@Autowired
	@Qualifier("builderTemplateServie")
	private IBuilderHtml builderTemplateServie;

	@RequestMapping(params = "action=buildHtml")
	public String buildHtml (HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		response.setContentType("html/txt");
		response.setCharacterEncoding("utf-8");
		try {
			builderTemplateServie.buildHtml();
			JSONObject object = new JSONObject();
			object.put("success", true);
			response.getWriter().print(object.toString());
		} catch (Exception e) {
			e.printStackTrace();
			log.error("生成模板控制器出错.", e);
		}
		return null;
	}
}
